Get the length and the angle of a complex numberΒΆ

Get the length and the angle of a complex number.
Expected output:
Length of a complex number: 5.0
Complex number Angle: 1.5707963267948966
import cmath

cn = complex(3, 4)

# length of a complex number
print("Length of a complex number: ", abs(cn))

# gets angle. return in radians
print("Complex number Angle: ", cmath.phase(0 + 1j) )

Output:

Length of a complex number: 5.0
Complex number Angle: 1.5707963267948966